package com.youlu.campus.service.tms.impl;

import com.alibaba.fastjson.JSON;
import com.youlu.campus.entity.ExpressCompany;
import com.youlu.campus.service.tms.ExpressCompanyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class ExpressCompanyServiceImpl implements ExpressCompanyService {
    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public ExpressCompany findByName(String name) {
        log.info(":>>> 开始查询快递100物流公司:{}", name);
        Query query = new Query().addCriteria(Criteria.where("name").is(name));
        ExpressCompany expressCompany = mongoTemplate.findOne(query, ExpressCompany.class);
        log.info(":>>> 物流公司:{},信息:{}", name, JSON.toJSON(expressCompany));
        return expressCompany;
    }
}
